import SimpleITK as sitk
import os
import cv2
import numpy as np

img_dir = "nnUNet/nnUNet_raw_data_base/nnUNet_raw_data/Task197_2Dwall/imagesTs"
name = '2Dwall_03000_0000.nii.gz'
output_dir = "sitk_test"

image = sitk.ReadImage(os.path.join(img_dir, name))
image = sitk.GetArrayFromImage(image)[0]

# image = image.swapaxes(0, 2)
image = np.rot90(image, -2)  # 顺时针旋转180°
# image = np.rot90(image, -1)  # 顺时针旋转90°

cv2.imwrite(os.path.join(output_dir, name.split(".")[0] + ".png"), image)


